export default {
  name: 'PostCard',
  props: {
    post: {
      type: Object,
      required: true
    }
  },
  template: `
    <div class="post-item">
      <div class="post-content" @click="goToPost(post.id)">
        <h3>{{ post.title }}</h3>
      </div>
      <div class="post-footer">
        <span class="post-time">{{ formatDate(post.created_at) }}</span>
        <div class="post-stats">
          <span class="stat-item">
            <el-icon><Star /></el-icon> {{ post.post_likes_count || 0 }}
          </span>
          <span class="stat-item">
            <el-icon><ChatLineRound /></el-icon> {{ post.comments_count || 0 }}
          </span>
        </div>
      </div>
    </div>
  `,
  methods: {
    formatDate(dateStr) {
      return new Date(dateStr).toLocaleString('zh-CN');
    },
    goToPost(postId) {
      this.$router.push(`/posts/${postId}`);
    }
  }
}; 